﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevExpress.Xpo;
using Zero.DataLayer.Donnees;
using Zero.DataLayer.Donnees.Tarifs;
using Zero.POCO;
using Zero.POCO.Compagne;
using Zero.POCO.Donnees;
using Zero.POCO.Enum.Helper.Support;
using Zero.POCO.FiltreEnumeration;
using Zero.POCO.Helper.Support;
using Zero.POCO.Support;
using AudienceJournal = Zero.POCO.Audiences.AudienceJournal;
using AudienceRadio = Zero.POCO.Audiences.AudienceRadio;
using AudienceTV = Zero.POCO.Audiences.AudienceTV;
using Signalitique = Zero.DataLayer.Donnees.Signalitique;
using Vague = Zero.POCO.Donnees.Vague;

namespace Zero.DataLayer.MAP
{
    public static class MapInverse
    {
        public static POCO.Donnees.Individu MapIndividus(Donnees.Individu individu)
        {
            return new POCO.Donnees.Individu()
                {
                    id = individu.Oid,
                    IdQuest = individu.IdQuest,
                    Sexe = individu.Sexe,
                    //TODO; convertir signalitique en données
                };
        }

        public static SupportPresse MapSupportPresse(XpoSupportPresse instance)
        {
            return new SupportPresse()
                {
                    id = instance.Oid,
                    Code = instance.Code,
                    Langue = instance.Langue,
                    Libelle = instance.Libelle,
                    Sujet = instance.Sujet,
                    Type = instance.Type
                };

        }

        public static SupportRadio MapSupportRadio(XpoSupportRadio instance)
        {
            return new SupportRadio()
            {
                id = instance.Oid,
                Code = instance.Code,
                Langue = instance.Langue,
                Libelle = instance.Libelle,
                Sujet = instance.Sujet,
                Type = instance.Type
            };
        }

        internal static SupportTV MapSupportTv(XpoSupportTV instance)
        {
            return new SupportTV()
            {
                id = instance.Oid,
                Code = instance.Code,
                Langue = instance.Langue,
                Libelle = instance.Libelle,
                Sujet = instance.Sujet,
                Type = instance.Type
            };
        }



        public static TarifPr MapTarifPresse(XpoTarifPr TarifPr)
        {
            var TarifPrinstance = new TarifPr()
            {
                id = TarifPr.Oid,
                Mois = TarifPr.Mois,
                annee = TarifPr.Annee,
                autre = TarifPr.Autre,
                nom = TarifPr.Nom
            };
            TarifPrinstance.supportPrs = new List<String>();
            foreach (var sup in TarifPr.SupportPresses)
            {
                TarifPrinstance.supportPrs.Add(sup.Libelle);
            }




            TarifPrinstance.LignesTarifPrs = new List<LignesTarifPr>();
            foreach (var lig in TarifPr.LigneTarifPrs)
            {
                TarifPrinstance.LignesTarifPrs.Add(MapLigneTarifPr(lig));
            }
            return TarifPrinstance;
        }


        public static LignesTarifPr MapLigneTarifPr(XpoLigneTarifPr ligneTarifPr)
        {
            return  new LignesTarifPr()
            {
                Format = ligneTarifPr.Format,
                id = ligneTarifPr.Oid,
                JourSemaine = ligneTarifPr.JourSemaine,
                Prix = ligneTarifPr.Prix
            };
        }










        public static TarifTv MapTarifTv(XpoTarifTv TarifTv)
        {
            var TarifTvinstance = new TarifTv()
            {
                id = TarifTv.Oid,
                Mois = TarifTv.Mois,
                annee = TarifTv.Annee,
                autre = TarifTv.Autre,
                nom = TarifTv.Nom
            };
            TarifTvinstance.supportTvs = new List<string>();
            foreach (var sup in TarifTv.SupportTvs)
            {
                TarifTvinstance.supportTvs.Add(sup.Libelle);
            }




            TarifTvinstance.LignesTarifTvs = new List<LignesTarifTv>();
            foreach (var lig in TarifTv.LigneTarifTvs)
            {
                TarifTvinstance.LignesTarifTvs.Add(MapLigneTarifTv(lig));
            }
            return TarifTvinstance;
        }


        public static LignesTarifTv MapLigneTarifTv(XpoLigneTarifTv ligneTarifTv)
        {
            return new LignesTarifTv()
            {
                duree = ligneTarifTv.Duree,
                id = ligneTarifTv.Oid,
                JourSemaine = ligneTarifTv.JourSemaine,
                Prix = ligneTarifTv.Prix,
                Debut = ligneTarifTv.Debut,
                Fin = ligneTarifTv.Fin
            };
        }





        public static TarifRd MapTarifRd(XpoTarifRd TarifRd)
        {
            var TarifRdinstance = new TarifRd()
            {
                id = TarifRd.Oid,
                Mois = TarifRd.Mois,
                annee = TarifRd.Annee,
                autre = TarifRd.Autre,
                nom = TarifRd.Nom
            };
            TarifRdinstance.supportRds = new List<string>();
            foreach (var sup in TarifRd.SupportRadios)
            {
                TarifRdinstance.supportRds.Add(sup.Libelle);
            }




            TarifRdinstance.LignesTarifRds = new List<LignesTarifRd>();
            foreach (var lig in TarifRd.LigneTarifRds)
            {
                TarifRdinstance.LignesTarifRds.Add(MapLigneTarifRd(lig));
            }
            return TarifRdinstance;
        }


        public static LignesTarifRd MapLigneTarifRd(XpoLigneTarifRd ligneTarifRd)
        {
            return new LignesTarifRd()
            {
                duree = ligneTarifRd.Duree,
                id = ligneTarifRd.Oid,
                JourSemaine = ligneTarifRd.JourSemaine,
                Prix = ligneTarifRd.Prix,
                Debut = ligneTarifRd.Debut,
                Fin = ligneTarifRd.Fin
            };
        }








        public static Vague MapVague(DataLayer.Donnees.Vague vague)
        {
            var vagueInstance= new Vague()
                {
                    Annee = vague.Annee,
                    Evenement = vague.Evenement,
                    id = vague.Oid,
                    Rang = vague.Rang,
                    Libelle = vague.Libelle,
                    Mois = vague.Mois,
                    Numero = vague.Numero,
                    Ecran = vague.Ecran,
                    DateDebut = vague.DateDebut,
                    NbJour = vague.NbJour,


                    NombreIndividus = vague.NombreIndividus,
                    NombreCalsse_A = vague.NombreCalsse_A,
                    NombreCalsse_B = vague.NombreCalsse_B,
                    NombreCalsse_C = vague.NombreCalsse_C,
                    NombreCalsse_D = vague.NombreCalsse_D,
                    NombreAlger = vague.NombreAlger,
                    NombreAutreInactif = vague.NombreAutreInactif,
                    NombreCadre = vague.NombreCadre,
                    NombreCadreMoyen = vague.NombreCadreMoyen,
                    NombreChomeur = vague.NombreChomeur,
                    NombreConstantine = vague.NombreConstantine,
                    NombreSansInstructionLireEtEcrire = vague.NombreSansInstructionLireEtEcrire,
                    NombreEmployee = vague.NombreEmployee,
                    NombreEntre_12_25 = vague.NombreEntre_12_25,
                    NombreEntre_25_55 = vague.NombreEntre_25_55,
                    NombreFemme = vague.NombreFemme,
                    NombreFemmeAuFoyer = vague.NombreFemmeAuFoyer,
                    NombreHautFonctionnaire = vague.NombreHautFonctionnaire,
                    NombreHomme = vague.NombreHommes,
                    NombreSansInstruction= vague.NombreSansInstruction,
                    NombreProfessionLiberal = vague.NombreProfessionLiberal,
                    NombreMoins_12 = vague.NombreMoins_12,
                    NombreMoyen = vague.NombreMoyen,
                    NombreOran = vague.NombreOran,
                    NombrePensionne = vague.NombrePensionne,
                    NombrePetitPatron = vague.NombrePetitPatron,
                    NombrePlus_55 = vague.NombrePlus_55,
                    NombrePrimaire = vague.NombrePrimaire,
                    NombreRetraite = vague.NombreRetraite,
                    NombreSetif = vague.NombreSetif,
                    NombreSecondaire = vague.NombreSecondaire,
                    NombreUniversitaire = vague.NombreUniversitaire,
                    

                };
            vagueInstance.Signalitique = new List<ISignalitique>();
            foreach (var sig in vague.Signalitiques)
            {
                vagueInstance.Signalitique.Add(MapSignalitique(sig));    
            }

            return vagueInstance;
        }

        private static ISignalitique MapSignalitique(Signalitique sig)
        {
            var sigInstance = new POCO.Donnees.Signalitique()
                {
                    Id=sig.Oid,
                    Ville = sig.Ville,
                    AppareilPhotoNumerique = sig.AppareilPhotoNumerique,
                    id = sig.Oid,
                    Age = sig.Age,
                    Aspirateur = sig.Aspirateur,
                    TypeHabitat = (TypeHabitation)sig.TypeHabitat,
                    TrancheAge = sig.TrancheAge,
                    Televisionencouleur = sig.Televisionencouleur,
                    Telephone = sig.Telephone,
                    TailleFoyer = (TailleFoyer)sig.TailleFoyer,
                    Statutfamilial = (StatutFamiliale)sig.Statutfamilial,
                    Situationmatrimoniale = (SituationMatrimonial)sig.Situationmatrimoniale,
                    SecheLinge = sig.SecheLinge,
                    RevenueTotalFoyer = (RevenuTotalFoyer)sig.RevenueTotalFoyer,
                    Refrigirateur = sig.Refrigirateur,
                    Poid = sig.Poid,
                    Pcsansconnexion = sig.Pcsansconnexion,
                    PCConnexion = sig.PCConnexion,
                    Niveau = sig.Niveau,
                    NbVoiture =sig.NbVoiture,
                    NbPiece = sig.NbPiece,
                    Mois = sig.Mois,
                    Mobile = sig.Mobile,
                    Magnetoscope = sig.Magnetoscope,
                    Lecteurradiocassette = sig.Lecteurradiocassette,
                    LecteurDVD = sig.LecteurDVD,
                    LecteurCD = sig.LecteurCD,
                    LaveVaissele = sig.LaveVaissele,
                    LaveLinge = sig.LaveLinge,
                    Jour = sig.Jour,
                    CSE = (CSE)sig.CSE,
                    Habitat = (Habitat)sig.Habitat,
                    Genre = (Genre)sig.Genre,
                    Fourmicroonde = sig.Fourmicroonde,
                    Decodeur = sig.Decodeur,
                    Cuisiniere = sig.Cuisiniere,
                    Console = sig.Console,
                    Congelateur = sig.Congelateur,
                    Climatiseur = sig.Climatiseur,
                    Chainestereo = sig.Chainestereo,
                    Camescope = sig.Camescope,
                    CSP = (CSP)sig.CSP,
                   
                    
                };
            /*if (sigInstance.AudienceJournals == null)
                sigInstance.AudienceJournals = new List<AudienceJournal>();
            foreach (var aud in sig.AudienceJournals)
            {
                sigInstance.AudienceJournals.Add(MapAudienceJournal(aud));
            }*/
           /* if (sigInstance.AudienceRadios==null)
                sigInstance.AudienceRadios = new List<AudienceRadio>();
            foreach (var aud in sig.AudienceRadios)
            {
                sigInstance.AudienceRadios.Add(MapAudienceRadio(aud));
            }*/
        /*    if (sigInstance.AudienceTVs == null)
                sigInstance.AudienceTVs = new List<AudienceTV>();
            foreach (var aud in sig.AudienceTVs)
            {
                sigInstance.AudienceTVs.Add(MapAudienceTv(aud));
            }*/

            sigInstance.Individu = MapIndividus(sig.Individu);

            return sigInstance;
        }

        public static List<AudienceTV> MapAudienceTv(Signalitique sigInstance,int dayOfWeek,int quart,string libelle)
        {
            var listeAudiencesTv = new List<AudienceTV>();
            sigInstance.AudienceTVs.CriteriaString = "NumeroJour== "+dayOfWeek+" AND NumeroQuertdheure == "+quart+" AND SupportTV.Libelle=='" + libelle+"'";
            foreach (var aud in sigInstance.AudienceTVs)
            {
                var audTv = new AudienceTV()
                {
                    id = aud.Oid,
                    NumeroJour = aud.NumeroJour,
                    NumeroQuertdheure = aud.NumeroQuertdheure,
                    Date = aud.Date,
                    Poid = aud.Poid,
                    Ville = aud.Ville,
                    CSE = aud.CSE,
                    CSP = aud.CSP,
                    Equipement = aud.Equipement,
                    Habitat = aud.Habitat,
                    NbPiece = aud.NbPiece,
                    NbVoiture = aud.NbVoiture,
                    Niveau = aud.Niveau,
                    RevenueTotalFoyer = aud.RevenueTotalFoyer,
                    Situationmatrimoniale = aud.Situationmatrimoniale,
                    Statutfamilial = aud.Statutfamilial,
                    TailleFoyer = aud.TailleFoyer,
                    TypeHabitat = aud.TypeHabitation,
                    Genre = aud.Genre,
                    NumeroJourSemaine = aud.NumeroJourSemaine
                };
                audTv.SupportTV = MapSupportTv(aud.SupportTV);

                listeAudiencesTv.Add(audTv);
            }
            return listeAudiencesTv;
        }

        private static List<AudienceRadio> MapAudienceRadio( Signalitique sig)
        {

            var listeAudiencesRd = new List<AudienceRadio>();
            foreach (var aud in sig.AudienceRadios)
            {
                var audRadio = new AudienceRadio()
                    {
                        NumeroJour = aud.NumeroJour,
                        id = aud.Oid,
                        QuartHeure = aud.QuartHeure,
                        Date = aud.Date,
                        Poid = aud.Poid,
                        Ville = aud.Ville,
                        CSE = aud.CSE,
                        CSP = aud.CSP,
                        Equipement = aud.Equipement,
                        Habitat = aud.Habitat,
                        NbPiece = aud.NbPiece,
                        NbVoiture = aud.NbVoiture,
                        Niveau = aud.Niveau,
                        RevenueTotalFoyer = aud.RevenueTotalFoyer,
                        Situationmatrimoniale = aud.Situationmatrimoniale,
                        Statutfamilial = aud.Statutfamilial,
                        TailleFoyer = aud.TailleFoyer,
                        TypeHabitat = aud.TypeHabitation,
                        Genre = aud.Genre,

                        NumeroJourSemaine = aud.NumeroJourSemaine
                    };

                audRadio.SupportRadio = MapSupportRadio(aud.SupportRadio);
                listeAudiencesRd.Add(audRadio);
            }
            return listeAudiencesRd;
        }


        private static List<AudienceJournal> MapAudienceJournal(Signalitique sig)
        {
            var ListeAudiencePresse = new List<AudienceJournal>();
            foreach (var aud in sig.AudienceJournals)
            {
            
                var audPresse= new AudienceJournal()
                    {
                        Jour = aud.Jour,
                        id = aud.Oid,
                        NombreOccurence = aud.NombreOccurence,
                        NumJournal = aud.NumJournal,
                        Date = aud.Date,
                        Ville = aud.Ville,
                        CSE = aud.CSE,
                        CSP = aud.CSP,
                        Equipement = aud.Equipement,
                        Habitat = aud.Habitat,
                        NbPiece = aud.NbPiece,
                        NbVoiture = aud.NbVoiture,
                        Niveau = aud.Niveau,
                        RevenueTotalFoyer = aud.RevenueTotalFoyer,
                        Situationmatrimoniale = aud.Situationmatrimoniale,
                        Statutfamilial = aud.Statutfamilial,
                        TailleFoyer = aud.TailleFoyer,
                        TypeHabitat = aud.TypeHabitation,
                        Genre = aud.Genre,

                        NumeroJourSemaine = aud.NumeroJourSemaine
                };
            audPresse.SupportPresse = MapSupportPresse(aud.SupportPresse).id;
            ListeAudiencePresse.Add(audPresse);
            } 
            return ListeAudiencePresse;
        }

        public static Compaign MapCampaign(XpoCompaign xpoCompaign)
        {

            var campagne = new Compaign
                {id = xpoCompaign.Oid,
                    Vague = MapVague(xpoCompaign.Vague),
                    Annonceur = MapAnnonceur(xpoCompaign.Annonceur),
                    Marque = MapMarque(xpoCompaign.Marque)
                };
            campagne.Filtre = MapFilter(xpoCompaign.Filter);
            campagne.PlanPresses = MapPlanPresse(xpoCompaign.PlanPresses);
            campagne.Name = xpoCompaign.Nom;
            //campagne.PlanRadios = MapPlanRd(xpoCompaign.PlanRadios);
            //campagne.PlanTvs = MapPlanTv(xpoCompaign.PlanTvs);
            return campagne;
        }

        public static List<PlanTV> MapPlanTv(XPCollection<XpoPlanTv> planTvs)
        {
            var listePlanTv = new List<PlanTV>();
            foreach (var xpoPlantv in planTvs)
            {
                var planTv = new PlanTV()
                {
                    id = xpoPlantv.Oid,
                    Name = xpoPlantv.Name
                };
                planTv.InsertionTvs=new List<InsertionTv>();
                if (xpoPlantv.XpoInsertionTVs != null && xpoPlantv.XpoInsertionTVs.Any())
                planTv.InsertionTvs.AddRange(MapInsertionTv(xpoPlantv.XpoInsertionTVs));

                if (xpoPlantv.XpoMapSupportTarifTvs != null && xpoPlantv.XpoMapSupportTarifTvs.Any())
                {
                    if (planTv.ListeMapSupportTarifs==null)
                        planTv.ListeMapSupportTarifs=new List<MapSupportTarif>();
                    planTv.ListeMapSupportTarifs.AddRange(MapMaptv(xpoPlantv.XpoMapSupportTarifTvs));
                }
                listePlanTv.Add(planTv);
            }
            return listePlanTv;
        }

        private static IEnumerable<MapSupportTarif> MapMaptv(XPCollection<XpoMapSupportTarifTv> xpoMapSupportTarifTvs)
        {
            List<MapSupportTarif> mapSupportTarifs = new List<MapSupportTarif>();
            foreach (var xpoMapSupportTarif in xpoMapSupportTarifTvs)
            {
                var mapsupport = new MapSupportTarif()
                {
                    id = xpoMapSupportTarif.Oid,
                    SupportId = xpoMapSupportTarif.supportTV.Oid,
                    TarifTv = MapTarifTv(xpoMapSupportTarif.TarifTv)
                };
                mapSupportTarifs.Add(mapsupport);

            }
            return mapSupportTarifs;
        }

        public static IEnumerable<InsertionTv> MapInsertionTv(XPCollection<XpoInsertionTV> xpoInsertionTVs)
        {
            var listeinsertion = xpoInsertionTVs.Select(xpoInsertionPress => new InsertionTv()
            {
                Date = xpoInsertionPress.Date,
                NumeroCinQMinute = xpoInsertionPress.NumeroQuartHeure,
                SupportTv = MapSupportTv(xpoInsertionPress.SupportTV)
            }).ToList();
            return listeinsertion;
        }

        public static List<PlanRadio> MapPlanRd(XPCollection<XpoPlanRadio> planRadios)
        {
            var listePlanRd = new List<PlanRadio>();
            foreach (var xpoPlanRadio in planRadios)
            {
                var planRd = new PlanRadio()
                    {
                        id = xpoPlanRadio.Oid,
                        Name = xpoPlanRadio.Name
                    };
                planRd.InsertionRadios=new List<InsertionRadio>();
                if (xpoPlanRadio.XpoInsertionRadios != null && xpoPlanRadio.XpoInsertionRadios.Any())
                planRd.InsertionRadios.AddRange(MapInsertion(xpoPlanRadio.XpoInsertionRadios));

                if (xpoPlanRadio.XpoMapSupportTarifRds != null && xpoPlanRadio.XpoMapSupportTarifRds.Any())
                {
                    if (planRd.ListeMapSupportTarifs == null)
                        planRd.ListeMapSupportTarifs = new List<MapSupportTarif>();
                    planRd.ListeMapSupportTarifs.AddRange(MapMapRadio(xpoPlanRadio.XpoMapSupportTarifRds));
                }
                listePlanRd.Add(planRd);
            }
            return listePlanRd;
        }

        private static IEnumerable<MapSupportTarif> MapMapRadio(XPCollection<XpoMapSupportTarifRd> xpoMapSupportTarifRds)
        {
            List<MapSupportTarif> mapSupportTarifs = new List<MapSupportTarif>();
            foreach (var xpoMapSupportTarif in xpoMapSupportTarifRds)
            {
                var mapsupport = new MapSupportTarif()
                {
                    id = xpoMapSupportTarif.Oid,
                    SupportId = xpoMapSupportTarif.supportRadio.Oid,
                    TarifRd = MapTarifRd(xpoMapSupportTarif.TarifRd)
                };
                mapSupportTarifs.Add(mapsupport);

            }
            return mapSupportTarifs;
        }

        public static List<InsertionRadio> MapInsertion(XPCollection<XpoInsertionRadio> xpoInsertionRadios)
        {
            var listeinsertion = xpoInsertionRadios.Select(xpoInsertionPress => new InsertionRadio()
            {
                Date = xpoInsertionPress.Date,
                NumeroCinQMinute = xpoInsertionPress.NumeroQuartHeure,
                SupportRadio = MapSupportRadio(xpoInsertionPress.SupportRadio)
            }).ToList();
            return listeinsertion;

        }

        public static List<PlanPresse> MapPlanPresse(XPCollection<XpoPlanPresse> XpoplanPresses)
        {
            var listePlan = new List<PlanPresse>();
            foreach (var XpoplanPress in XpoplanPresses)
            {
                var planPr = new PlanPresse()
                    {
                        id = XpoplanPress.Oid,
                        Name = XpoplanPress.Name,
                    };
                planPr.InsertionPresses=new List<InsertionPresse>();
                if (XpoplanPress.XpoInsertionPresses != null && XpoplanPress.XpoInsertionPresses.Any())
                planPr.InsertionPresses.AddRange(MapInsertionPresse(XpoplanPress.XpoInsertionPresses));

                if (XpoplanPress.XpoMapSupportTarifPrs != null && XpoplanPress.XpoMapSupportTarifPrs.Any())
                {
                    if (planPr.ListeMapSupportTarifs == null)
                        planPr.ListeMapSupportTarifs = new List<MapSupportTarif>();
                    planPr.ListeMapSupportTarifs.AddRange(MapMapPresse(XpoplanPress.XpoMapSupportTarifPrs));
                }

                    listePlan.Add(planPr);
            }
            return listePlan;
        }

        private static List<MapSupportTarif> MapMapPresse(XPCollection<XpoMapSupportTarifPr> xpoMapSupportTarifPrs)
        {
            List<MapSupportTarif> mapSupportTarifs=new List<MapSupportTarif>();
            foreach (var xpoMapSupportTarif in xpoMapSupportTarifPrs)
            {
                var mapsupport = new MapSupportTarif()
                {
                    id = xpoMapSupportTarif.Oid,
                    SupportId = xpoMapSupportTarif.supportPresse.Oid,
                    TarifPr = MapTarifPresse(xpoMapSupportTarif.tarifPr)
                };
                mapSupportTarifs.Add(mapsupport);

            }
            return mapSupportTarifs;
        }

        public static List<InsertionPresse> MapInsertionPresse(XPCollection<XpoInsertionPresse> xpoInsertionPresses)
        {
            var listeinsertion = xpoInsertionPresses.Select(xpoInsertionPress => new InsertionPresse()
                {
                    Date = xpoInsertionPress.Date, NombreFoisLus = xpoInsertionPress.NombreFoisLus, SupportPresse = MapSupportPresse(xpoInsertionPress.SupportPresse)
                }).ToList();
            return listeinsertion;
        }


        public static Filter MapFilter(XpoFilter xpoFilter)
        {
            return new Filter()
                {
                    id = xpoFilter.Oid,
                    ageMin = xpoFilter.ageMin,
                    ageMax = xpoFilter.ageMax,
                    CSEs = xpoFilter.CSEs,
                    CSPs = xpoFilter.CSPs,
                    Equipements = xpoFilter.Equipement,
                    Genres = xpoFilter.Genre,
                    Habitats = xpoFilter.Habitat,
                    NbChambres = xpoFilter.NbChambre,
                    NbVoitures = xpoFilter.NbVoiture,
                    NiveauxInstructions = xpoFilter.NiveauInstruction,
                    Nom = xpoFilter.Nom,
                    RevenueTotalFoyers = xpoFilter.RevenuTotalFoyer,
                    SituationMatrimonials = xpoFilter.SituationMatrimonial,
                    StatutFamiliales = xpoFilter.StatutFamiliale,
                    TailleFoyers = xpoFilter.TailleFoyer,
                    TypeHabitations = xpoFilter.TypeHabitation,
                    Representativite = xpoFilter.Representativite
                };
        }

        public static Annonceur MapAnnonceur(XpoAnnonceur annonceur)
        {
            var ann=new Annonceur()
                {
                    id = annonceur.Oid,
                    Name = annonceur.Name
                };
            ann.Marques=new List<Marque>();
            foreach (var marque in annonceur.Marques)
            {
                ann.Marques.Add(MapMarque(marque));
            }
            return ann;
        }

        public static Marque MapMarque(XpoMarque marque)
        {
            return new Marque()
                {
                    Name = marque.Name,
                    id = marque.Oid,
                    Type = marque.Type
                };
        }
    }
}
